package com.luyuan.crm.member.web.converter;

import java.util.Date;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import org.springframework.stereotype.Component;

import com.ruijie.util.DateUtils;

@Component("ageConverter")
public class AgeConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return null;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value instanceof Date) {
            return String.valueOf(DateUtils.getYear(new Date()) - DateUtils.getYear((Date) value));
        }
        return null;
    }

}
